#include "statusbar.h"
#include <QtGui>

StatusBar::StatusBar(QWidget *parent) :
    QStatusBar(parent)
{
    statusIcon = new QLabel(this);
    statusIcon->setObjectName("statusBarStatusIcon");
    statusIcon->setFixedSize(DEFAULT_TWIT_STATUS_ICON_SIZE, DEFAULT_TWIT_STATUS_ICON_SIZE);

    statusText = new QLabel(this);
    statusText->setObjectName("statusBarText");

    icon = new QMovie(this);

    setObjectName("statusBar");
    insertPermanentWidget(0, statusIcon);
    insertWidget(1, statusText, 1);
}

void StatusBar::setStatusIcon(Queue::STATE state)
{
    icon->stop();
    switch(state)
    {
            case Queue::NOT_RUNNING:
            {
                icon->setFileName(DEFAULT_TWIT_STATUSUP_ICON);
                statusIcon->setToolTip(tr("Update successful"));
            break;
            }
            case Queue::FREEZE:
            {
                icon->setFileName(DEFAULT_TWIT_STATUSDOWN_ICON);
                statusIcon->setToolTip(tr("Update is not successful"));
            break;
            }
            case Queue::WAIT_ANSWER:
            {
                icon->setFileName(DEFAULT_TWIT_STATUSUPDATE_ICON);
                statusIcon->setToolTip(tr("Updating..."));
            break;
            }
    }

    statusIcon->setMovie(icon);
    icon->start();
}

StatusBar::~StatusBar()
{

}
